﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MLopez.BizVal.CW.Base
{
    /// <summary>
    /// Clasificador de excepciones <c>CWException</c>
    /// </summary>
    public enum CWExceptionType
    {
        /// <summary></summary>
        ImproperLabelValues,
        /// <summary></summary>
        IndexOutOfRange,
        /// <summary></summary>
        NoLabelSet,
        /// <summary></summary>
        LabelNotInSet,
        /// <summary></summary>
        BetaOutOfRange,
        /// <summary></summary>
        SymTranslationOutOfRange,
        /// <summary></summary>
        HierarchyLevelMissed,
        /// <summary></summary>
        HierarchyCardinalityError,
    }


    /// <summary>
    /// Excepción genérica en computación con palabras.
    /// </summary>
    public class CWException:Exception
    {
        /// <summary>
        /// Lanza una nueva excepción CW del tipo indicado
        /// </summary>
        /// <param name="type">Tipo de excepción</param>
        public CWException(CWExceptionType type)
        {
            switch (type)
            {
                case CWExceptionType.ImproperLabelValues: new Exception("Indice fuera de rango para el conjunto de etiquetas"); break;
                case CWExceptionType.IndexOutOfRange: new Exception("Valores no válidos para inicializar una etiqueta triangular"); break;
                case CWExceptionType.NoLabelSet: new Exception("Labels Set Not Initialized"); break;
                case CWExceptionType.LabelNotInSet: new Exception("The label you are trying to operate with is not in the defined label set"); break;
                case CWExceptionType.BetaOutOfRange: new Exception("The value for Beta parameter is not valid"); break;
                case CWExceptionType.SymTranslationOutOfRange: new Exception("Symbolic translation out of range. Must be in [-0.5, 0.5)"); break;
                case CWExceptionType.HierarchyLevelMissed: new Exception("Hierarchy level missed. You need to define lower levels first."); break;
                case CWExceptionType.HierarchyCardinalityError: new Exception("Hierarchy level cardinality error"); break;
                default: new Exception(); break;
            }
        }
    }
}
